<?php

/*
 * 活动类
 */

namespace Home\Logic;

class AreaLogic {

    const DEFAULT_PEOVINCE = 110000;
    const DEFAULT_CITY = 110100;

    public function __construct() {
        $this->p = D('Provinces');
        $this->c = D('Cities');
        $this->a = D('Areas');
    }

    public function getProvinces() {
        return $this->p->select();
    }
    
    public function getCities($pid){
        if($pid<1){
            $pid = self::DEFAULT_PEOVINCE;
        }
        return $this->c->where(array('provinceid'=>$pid))->select();
    }
    
    public function getAreas($cid){
        if($cid<1){
            $cid = self::DEFAULT_CITY;
        }
        return $this->a->where(array('cityid'=>$cid))->select();
    }

}
